<?php
namespace Deployer;

require 'recipe/laravel.php';

// Project name
set('application', 'myBlog');

// Project repository
set('repository', 'https://gitee.com/lovews28/myBlog.git');

// [Optional] Allocate tty for git clone. Default value is false.
//set('git_tty', true);

// Shared files/dirs between deploys 
add('shared_files', []);
add('shared_dirs', []);

// Writable dirs by web server 
add('writable_dirs', []);

// 保存最近五次部署，这样的话回滚最多也只能回滚到前 5 个版本
set('keep_releases', 5);

// 实践证明，这样能减少一些不必要的麻烦,如出现权限相关的问题，也可将此项设置为 true 后尝试
set('writable_use_sudo', false);

// Hosts

host('94.191.20.106')
    ->stage('debug')
    ->user('root')
    ->port(22)
    ->set('branch', 'master') // 一般是把 develop 分支弄到测试机测试，没问题再合并
    ->set('deploy_path', '/data/html/www')
    ->identityFile('~/.ssh/deployerkey')
    ->set('http_user', 'www')
    ->addSshOption('UserKnownHostsFile', '/dev/null')
    ->addSshOption('StrictHostKeyChecking', 'no');
    
// Tasks

task('build', function () {
    run('cd {{release_path}} && build');
});

// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');

// Migrate database before symlink new release.

before('deploy:symlink', 'artisan:migrate');

